
/**
 * Created by cc
 * Description:
 * User: CZH
 * Date: 2022-09-24
 * Time: 16:02
 */
public class Test01 {

    public static void main(String[] args) {
        String str = "abcdefg";
        System.out.println(firstUpper(str));
    }
    public static String firstUpper(String str) {
        if (" ".equals(str) || str == null) {
            return str;
        }
        if (str.length() > 0) {
            return str.substring(0,1).toUpperCase() + str.substring(1);
        }
        return str.toUpperCase();
    }


    public static void main16(String[] args) {
        String str = "hello";
        byte[] bytes = str.getBytes();
        for (int i = 0; i < bytes.length; i++) {
            System.out.print(bytes[i] + " ");
        }

        System.out.println(new String(bytes));
    }

    public static void main15(String[] args) {
        String str = "123a456";
        System.out.println(isNum(str));
    }
    public static boolean isNum(String str) {
        char[] chars = str.toCharArray();
        for (int i = 0; i < chars.length; i++) {
            if (chars[i] > '9' || chars[i] < '0') {
                return false;
            }
        }
        return true;
    }

    public static void main14(String[] args) {
        String str = "helloworld";
        System.out.println(str.substring(5));
        System.out.println(str.substring(0,5));
    }

    public static void main13(String[] args) {
        String str = "name=zhangsan&age=18";
        String[] strings = str.split("&");
        for (int i = 0; i < strings.length; i++) {
            String[] str1 = strings[i].split("=");
            System.out.println(str1[0]);
            System.out.println(str1[1]);
        }
    }

    public static void main12(String[] args) {
        String str = "hello world !";
        String str2 = "192.168.1.0";
        String[] result = str.split(" ", 2);
        String[] strings = str2.split("\\.");
        for (String s : strings) {
            System.out.print(s + " ");
        }
    }

    public static void main11(String[] args) {
        String str = "hello";
        System.out.println(str.contains("lol"));
    }

    public static void main10(String[] args) {
        String str = "helloworld";
        byte[] data = str.getBytes();
        for (int i = 0; i < data.length; i++) {
            System.out.print(data[i] + " ");
        }
        System.out.println();
        System.out.println(new String(data));
    }

    public static void main9(String[] args) {
        String str = "12a3456";
        System.out.println(isNumber(str)?"全部是数字":"不全是数字");
    }
    public static boolean isNumber(String string){
        char[] data = string.toCharArray();
        for (int i = 0; i < data.length; i++) {
            if (data[i] > '9' || data[i] < '0') {
                return false;
            }
        }
        return true;
    }

    public static void main8(String[] args) {
        String string = "hello";
        char[] data = string.toCharArray();
        for (int i = 0; i < data.length; i++) {
            System.out.println(data[i]);
        }
        System.out.println(new String(data));
        System.out.println(new String(data, 0, 5));
    }

    public static void main7(String[] args) {
        String string = "hello";
        System.out.println(string.charAt(0));
//        System.out.println(string.charAt(10));
    }

    public static void main6(String[] args) {
        String string = "hello";
        string += " world";
        string += "!!!";
        System.out.println(string);
    }

    public static void main5(String[] args) {
        String str1 = new String("hello").intern();
        String str2 = "hello";
        System.out.println(str1 == str2);
    }

    public static void main4(String[] args) {
        String str1 = new String("hello");
        str1 = null;
//        System.out.println(str1.equals("hello"));
        System.out.println("hello".equals(str1));
    }

    public static void main3(String[] args) {
        String str1 = new String("hello");
        String str2 = new String("hello");
        String str3 = "hello";
        String str4 = "hello";
        System.out.println(str3 == str4);
        System.out.println(str1 == str2);
        System.out.println(str1 == str4);
    }

    public static void main2(String[] args) {
        String str1 = "hello";
        String str2 = str1;
        str1 = "world";
        System.out.println(str1);
        System.out.println(str2);
    }

    public static void main1(String[] args) {
        String str1 = "hello";
        String str2 = new String("hello");
        char[] chars = {'h','e','l','l','o'};
        String str3 = new String(chars);
    }
}
